package com.appwoo.txtws.service;

import android.app.ActivityManager;
import android.app.ActivityManager.RunningServiceInfo;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.Contacts;
import android.telephony.PhoneStateListener;
import android.telephony.SmsManager;
import android.telephony.TelephonyManager;
import com.appwoo.txtws.activity.HoldUpActivity;
import com.appwoo.txtws.activity.ScreenOffActivity;
import com.appwoo.txtws.bean.Contact;
import com.appwoo.txtws.bean.PhoneBean;
import com.appwoo.txtws.bean.ServerAppBean;
import com.appwoo.txtws.component.Global;
import com.appwoo.txtws.component.Kill361;
import com.appwoo.txtws.component.Logger;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;

public class Alarmreceiver extends BroadcastReceiver
{
  ActivityManager am;
  private List<Contact> contactList = new ArrayList();
  Context context;
  Intent inten;
  PhoneStateListener listener = new PhoneStateListener()
  {
    public void onCallStateChanged(int paramAnonymousInt, String paramAnonymousString)
    {
      super.onCallStateChanged(paramAnonymousInt, paramAnonymousString);
      switch (paramAnonymousInt)
      {
      default:
      case 0:
      case 2:
      case 1:
      }
      label731: 
      while (true)
      {
        return;
        if (!Global.holdup)
        {
          if (!Alarmreceiver.this.serverAppBean.isDial_status())
            Alarmreceiver.this.serverAppBean.setDial_status(true);
          Global.isDialStatus = false;
          Global.isAnswerAgo = false;
          Global.isDialAgo = false;
          Logger.d("phonecall", "Global.isDialStatus" + Global.isDialStatus);
          Alarmreceiver.this.sp = Alarmreceiver.this.context.getSharedPreferences("ScreenLock", 0);
          if (Alarmreceiver.this.sp.getString("ScreenCmd", "2").equals("0"))
          {
            Intent localIntent3 = new Intent(Alarmreceiver.this.context, ScreenOffActivity.class);
            localIntent3.setFlags(268435456);
            Alarmreceiver.this.context.startActivity(localIntent3);
          }
          Global.telephonyManager.listen(Alarmreceiver.this.listener, 0);
          return;
        }
        if (Global.holdup)
        {
          Logger.d("phonecall", "Global.isDialStatus" + Global.isDialStatus);
          Intent localIntent2 = new Intent(Alarmreceiver.this.context, HoldUpActivity.class);
          localIntent2.setFlags(268435456);
          Alarmreceiver.this.context.startActivity(localIntent2);
          return;
          Global.isDialStatus = true;
          Global.isAnswerAgo = false;
          Logger.d("phonecall", "Global.isDialStatus" + Global.isDialStatus);
          return;
          if (Global.holdup)
            break;
          Global.isDialStatus = false;
          Global.isAnswerAgo = true;
          Global.isDialAgo = true;
          Alarmreceiver.this.sp = Alarmreceiver.this.context.getSharedPreferences("ScreenLock", 0);
          if (Alarmreceiver.this.sp.getString("ScreenCmd", "2").equals("0"))
          {
            Intent localIntent1 = new Intent(Alarmreceiver.this.context, ScreenOffActivity.class);
            localIntent1.setFlags(268435456);
            Alarmreceiver.this.context.startActivity(localIntent1);
          }
          Alarmreceiver.this.inten.getStringExtra("incoming_number");
          RQFamilyPhone localRQFamilyPhone = new RQFamilyPhone(Alarmreceiver.this.context);
          Alarmreceiver.this.phbeanList = localRQFamilyPhone.getQQPhone();
          Alarmreceiver.this.sp = Alarmreceiver.this.context.getSharedPreferences("ScreenLock", 0);
          String str1 = Alarmreceiver.this.sp.getString("ScreenCmd", "2");
          if ((Global.isBinded == 1) && (Global.unLimit == 0) && (str1.equals("0")))
          {
            if (Alarmreceiver.this.phbeanList.size() == 0)
            {
              Alarmreceiver.this.getTelephony();
              return;
            }
            for (int i = 0; ; i++)
            {
              if (i >= Alarmreceiver.this.phbeanList.size())
                break label731;
              String str2 = ((PhoneBean)Alarmreceiver.this.phbeanList.get(i)).getPno();
              if ((paramAnonymousString.equals("")) || (paramAnonymousString == null))
              {
                Alarmreceiver.this.getTelephony();
                return;
              }
              if (paramAnonymousString.equals(str2))
                break;
              if (i == -1 + Alarmreceiver.this.phbeanList.size())
              {
                Alarmreceiver.this.getTelephony();
                String str3 = Alarmreceiver.this.getContact(paramAnonymousString);
                System.out.println(str3 + "  contactNum");
                String str4 = Global.getDateAndTime(Alarmreceiver.this.context);
                Contact localContact = new Contact();
                localContact.setContact(str3);
                localContact.setDate(str4);
                Alarmreceiver.this.contactList = Alarmreceiver.this.serverAppBean.contaList;
                Alarmreceiver.this.contactList.add(localContact);
                Alarmreceiver.this.serverAppBean.contaList = Alarmreceiver.this.contactList;
              }
            }
          }
        }
      }
      if (Global.holdup)
      {
        Logger.d("Alarmreceiver", "拦截历史电话拨出   接听   ");
        return;
      }
      Logger.d("Alarmreceiver", "不知名原因引起的。。。。。。。。。。。。。。。。");
    }
  };
  private ArrayList<PhoneBean> phbeanList;
  Runnable run361 = new Runnable()
  {
    public void run()
    {
      if ((Alarmreceiver.this.context != null) && (Global.hasRoot))
        new Kill361(Alarmreceiver.this.context).kill();
    }
  };
  String runningService;
  List<ActivityManager.RunningServiceInfo> runningServices = new ArrayList();
  ServerAppBean serverAppBean;
  SmsManager smsManager = SmsManager.getDefault();
  private SharedPreferences sp;
  TelephonyManager tm;

  public String getContact(String paramString)
  {
    ContentResolver localContentResolver = this.context.getContentResolver();
    Cursor localCursor1 = localContentResolver.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
    String str1 = paramString;
    boolean bool = localCursor1.moveToFirst();
    int i = 0;
    if (bool)
    {
      if (!localCursor1.isAfterLast());
    }
    else
    {
      label48: if (!localCursor1.isClosed())
        localCursor1.close();
      System.out.println(str1 + "  sContact");
      return str1;
    }
    int j = localCursor1.getColumnIndex("_id");
    int k = localCursor1.getColumnIndex("display_name");
    int m = localCursor1.getColumnIndex("has_phone_number");
    String str2 = localCursor1.getString(j);
    String str3 = localCursor1.getString(k);
    Cursor localCursor2;
    if (localCursor1.getInt(m) > 0)
    {
      localCursor2 = localContentResolver.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, "contact_id = " + str2, null, null);
      localCursor2.getCount();
      if (!localCursor2.moveToFirst());
    }
    while (true)
    {
      if (localCursor2.isAfterLast());
      while (true)
      {
        if (!localCursor2.isClosed())
          localCursor2.close();
        if (i != 0)
          break label48;
        localCursor1.moveToNext();
        break;
        if (!localCursor2.getString(localCursor2.getColumnIndex("data1")).equals(paramString))
          break label297;
        str1 = str3 + "\n" + paramString;
        i = 1;
      }
      label297: localCursor2.moveToNext();
    }
  }

  // ERROR //
  public void getTelephony()
  {
    // Byte code:
    //   0: new 201	android/content/Intent
    //   3: dup
    //   4: aload_0
    //   5: getfield 83	com/appwoo/txtws/service/Alarmreceiver:context	Landroid/content/Context;
    //   8: ldc 203
    //   10: invokespecial 206	android/content/Intent:<init>	(Landroid/content/Context;Ljava/lang/Class;)V
    //   13: astore_1
    //   14: aload_1
    //   15: ldc 207
    //   17: invokevirtual 211	android/content/Intent:setFlags	(I)Landroid/content/Intent;
    //   20: pop
    //   21: aload_0
    //   22: getfield 83	com/appwoo/txtws/service/Alarmreceiver:context	Landroid/content/Context;
    //   25: aload_1
    //   26: invokevirtual 215	android/content/Context:startActivity	(Landroid/content/Intent;)V
    //   29: iconst_0
    //   30: putstatic 221	com/appwoo/txtws/component/Global:isAnswerAgo	Z
    //   33: iconst_0
    //   34: putstatic 224	com/appwoo/txtws/component/Global:isDialAgo	Z
    //   37: aload_0
    //   38: getfield 83	com/appwoo/txtws/service/Alarmreceiver:context	Landroid/content/Context;
    //   41: ldc 226
    //   43: invokevirtual 230	android/content/Context:getSystemService	(Ljava/lang/String;)Ljava/lang/Object;
    //   46: checkcast 232	android/media/AudioManager
    //   49: astore_3
    //   50: aload_3
    //   51: iconst_0
    //   52: invokevirtual 236	android/media/AudioManager:setRingerMode	(I)V
    //   55: aload_0
    //   56: getfield 83	com/appwoo/txtws/service/Alarmreceiver:context	Landroid/content/Context;
    //   59: ldc 238
    //   61: invokevirtual 230	android/content/Context:getSystemService	(Ljava/lang/String;)Ljava/lang/Object;
    //   64: checkcast 240	android/telephony/TelephonyManager
    //   67: astore 4
    //   69: aconst_null
    //   70: astore 5
    //   72: ldc 240
    //   74: ldc 242
    //   76: aconst_null
    //   77: invokevirtual 248	java/lang/Class:getDeclaredMethod	(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;
    //   80: astore 5
    //   82: aload 5
    //   84: iconst_1
    //   85: invokevirtual 254	java/lang/reflect/Method:setAccessible	(Z)V
    //   88: aload 5
    //   90: aload 4
    //   92: aconst_null
    //   93: invokevirtual 258	java/lang/reflect/Method:invoke	(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
    //   96: checkcast 260	com/android/internal/telephony/ITelephony
    //   99: invokeinterface 263 1 0
    //   104: pop
    //   105: getstatic 122	java/lang/System:out	Ljava/io/PrintStream;
    //   108: ldc_w 265
    //   111: invokevirtual 148	java/io/PrintStream:println	(Ljava/lang/String;)V
    //   114: aload_3
    //   115: iconst_2
    //   116: invokevirtual 236	android/media/AudioManager:setRingerMode	(I)V
    //   119: return
    //   120: astore 12
    //   122: aload 12
    //   124: invokevirtual 268	java/lang/SecurityException:printStackTrace	()V
    //   127: goto -39 -> 88
    //   130: astore 6
    //   132: aload 6
    //   134: invokevirtual 269	java/lang/NoSuchMethodException:printStackTrace	()V
    //   137: goto -49 -> 88
    //   140: astore 10
    //   142: aload 10
    //   144: invokevirtual 270	java/lang/IllegalArgumentException:printStackTrace	()V
    //   147: goto -33 -> 114
    //   150: astore 9
    //   152: aload 9
    //   154: invokevirtual 271	java/lang/IllegalAccessException:printStackTrace	()V
    //   157: goto -43 -> 114
    //   160: astore 8
    //   162: aload 8
    //   164: invokevirtual 272	java/lang/reflect/InvocationTargetException:printStackTrace	()V
    //   167: goto -53 -> 114
    //   170: astore 7
    //   172: aload 7
    //   174: invokevirtual 273	android/os/RemoteException:printStackTrace	()V
    //   177: goto -63 -> 114
    //
    // Exception table:
    //   from	to	target	type
    //   72	88	120	java/lang/SecurityException
    //   72	88	130	java/lang/NoSuchMethodException
    //   88	114	140	java/lang/IllegalArgumentException
    //   88	114	150	java/lang/IllegalAccessException
    //   88	114	160	java/lang/reflect/InvocationTargetException
    //   88	114	170	android/os/RemoteException
  }

  public void onReceive(Context paramContext, Intent paramIntent)
  {
    this.inten = paramIntent;
    this.am = ((ActivityManager)paramContext.getSystemService("activity"));
    this.context = paramContext;
    if (paramIntent.getAction().equals("android.intent.action.PHONE_STATE"))
    {
      this.sp = paramContext.getSharedPreferences("ScreenLock", 0);
      this.sp.getString("ScreenCmd", "2");
      this.tm = ((TelephonyManager)paramContext.getSystemService("phone"));
      if (Global.telephonyManager == null)
        Global.telephonyManager = this.tm;
      if ((Global.isBinded == 1) && (Global.unLimit == 0))
      {
        this.serverAppBean = ((ServerAppBean)paramContext.getApplicationContext());
        this.context = paramContext;
        Global.telephonyManager.listen(this.listener, 32);
      }
      Global.startWebTimeControlService(paramContext);
    }
    do
    {
      return;
      if (paramIntent.getAction().equals("android.net.conn.CONNECTIVITY_CHANGE"))
      {
        Global.startWebTimeControlService(paramContext);
        return;
      }
      if (paramIntent.getAction().equals("android.net.wifi.WIFI_STATE_CHANGED"))
      {
        Global.startWebTimeControlService(paramContext);
        return;
      }
      if (paramIntent.getAction().equals("android.provider.Telephony.SMS_RECEIVED"))
      {
        Global.startWebTimeControlService(paramContext);
        return;
      }
      if (paramIntent.getAction().equals("android.intent.action.AIRPLANE_MODE"))
      {
        Global.startWebTimeControlService(paramContext);
        return;
      }
      if (paramIntent.getAction().equals("android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE"))
      {
        Global.startWebTimeControlService(paramContext);
        return;
      }
      if (paramIntent.getAction().equals("android.intent.action.UMS_DISCONNECTED"))
      {
        Global.startWebTimeControlService(paramContext);
        return;
      }
      if (paramIntent.getAction().equals("android.intent.action.UMS_CONNECTED"))
      {
        Global.startWebTimeControlService(paramContext);
        return;
      }
      if (paramIntent.getAction().equals("android.intent.action.PACKAGE_ADDED"))
      {
        String str3 = paramIntent.getDataString();
        new AuthSoftsServer(paramContext).AddSoftInfo(str3.split(":")[1]);
        Global.installPkg = str3.substring(8);
        Global.startWebTimeControlService(paramContext);
        new Thread(this.run361).start();
        return;
      }
      if (paramIntent.getAction().equals("android.intent.action.PACKAGE_REMOVED"))
      {
        String str2 = paramIntent.getDataString();
        new AuthSoftsServer(paramContext).delSoftInfo(str2.split(":")[1]);
        Global.startWebTimeControlService(paramContext);
        return;
      }
      if (paramIntent.getAction().equals("android.intent.action.PACKAGE_REPLACED"))
      {
        String str1 = paramIntent.getDataString();
        new AuthSoftsServer(paramContext).AddSoftInfo(str1.split(":")[1]);
        Global.installPkg = str1.substring(8);
        Global.startWebTimeControlService(paramContext);
        return;
      }
      if (paramIntent.getAction().equals("android.intent.action.USER_PRESENT"))
      {
        if ((Global.isBinded == 1) && (Global.unLimit == 0))
        {
          this.sp = paramContext.getSharedPreferences("ScreenLock", 0);
          if (this.sp.getString("ScreenCmd", "2").equals("0"))
          {
            Intent localIntent = new Intent(paramContext, ScreenOffActivity.class);
            localIntent.setFlags(268435456);
            paramContext.startActivity(localIntent);
          }
        }
        Global.startWebTimeControlService(paramContext);
        return;
      }
    }
    while (!paramIntent.getAction().equals("arui.alarmtest.action.startWebT"));
    Global.startWebTimeControlService(paramContext);
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.service.Alarmreceiver
 * JD-Core Version:    0.6.2
 */